gh-149050: Fix return type of ConfigParser.items() in documentation#150059
Open
Taeknology wants to merge 1 commit into
Open
gh-149050: Fix return type of ConfigParser.items() in documentation#150059Taeknology wants to merge 1 commit into
Taeknology wants to merge 1 commit into
Conversation
…tion When called without a section argument, ConfigParser.items() delegates to dict.items() and returns a collections.abc.ItemsView, not a list. The docs previously described both overloads as returning a list.
Documentation build overview
|
Member
StanFromIreland
left a comment
There was a problem hiding this comment.
Also fix the case noted in #149050 (comment) please.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
ConfigParser.items()is called without a section argument, theimplementation delegates to
super().items()(i.e.dict.items()) andreturns a
collections.abc.ItemsView, not alist. The docs previouslydescribed both overloads as returning a
list, which is only correctfor the second overload (with a section argument).
This PR adjusts the first paragraph of the
items()documentation inDoc/library/configparser.rstto sayItemsViewinstead oflist.The second paragraph (with-
sectionoverload) is unchanged becausethat one really does return a
list.Verified locally (against
Lib/configparser.pyonmain)I isolated
cpython/Lib/configparser.pyfrom the working tree andloaded it with
importlib.utilto confirm the behaviour on currentmain(not just the installed interpreter):Result:
git log -L:'def items':Lib/configparser.pyshows the body ofitems()has not been touched since199507b81a(a docstring-onlyrst-markup fix), so this is a long-standing docs/behaviour mismatch
rather than a recent regression.
No code change. No
Misc/NEWS.dentry (docs-only).Fixes #149050
configparser.ConfigParser.itemsreturns acollections.abc.ItemsViewin the first overload #149050